home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Font Fun / FullFit / FullFit.cs next >
Encoding:
Text File  |  2001-01-15  |  1.3 KB  |  43 lines

  1. //-----------------------------------------
  2. // FullFit.cs ⌐ 2001 by Charles Petzold
  3. //-----------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class FullFit: FontMenuForm
  10. {
  11.      public new static void Main()
  12.      {
  13.           Application.Run(new FullFit());
  14.      }
  15.      public FullFit()
  16.      {
  17.           Text = "Full Fit";
  18.  
  19.           strText = "Full Fit";
  20.           font = new Font("Times New Roman", 108);
  21.      }
  22.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  23.      {
  24.           GraphicsPath path = new GraphicsPath();
  25.                
  26.                // Add text to the path.
  27.  
  28.           path.AddString(strText, font.FontFamily, (int) font.Style,
  29.                          100, new Point(0, 0), new StringFormat());
  30.  
  31.                // Set the world transform.
  32.  
  33.           RectangleF rectfBounds = path.GetBounds();
  34.           PointF[]   aptfDest    = { new PointF(0, 0), new PointF(cx, 0),
  35.                                                        new PointF(0, cy) };
  36.           
  37.           grfx.Transform = new Matrix(rectfBounds, aptfDest);
  38.  
  39.                // Fill the path.
  40.  
  41.           grfx.FillPath(new SolidBrush(clr), path);
  42.      }
  43. }